from django.db import models

# Create your models here.

# 用户表
class User(models.Model):
    username = models.CharField(max_length=64,unique=True,null=False,verbose_name='账号')
    password = models.CharField(max_length=64,null=False,verbose_name='密码')

# 物品表
class Item(models.Model):
    status_choice=[('available','available'),('sold','sold')]
    title = models.CharField(max_length=255,null=False,verbose_name='商品标题')
    price = models.DecimalField(max_digits=10,decimal_places=2,null=False,verbose_name='商品价格')
    seller_id = models.IntegerField(verbose_name='买家id',null=False)
    status = models.CharField(max_length=64,choices=status_choice,default='available',verbose_name='商品状态')
    user_id = models.ForeignKey(User,on_delete=models.CASCADE,related_name='item')


